package com.example.demo.controller

import com.example.demo.service.BedService
import com.example.demo.service.BoardService
import com.example.demo.utils.MResult
import com.example.demo.vo.BedInfoVo
import com.example.demo.vo.CareLabelVo
import com.example.demo.vo.MessageVo
import com.example.demo.vo.PatientVo
import com.example.demo.vo.board.NurseLevelVo
import com.example.demo.vo.board.ScheduleVo
import com.example.demo.vo.board.ShiftPlanInfo
import com.example.demo.vo.board.ShiftPlanVo
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import io.swagger.annotations.ApiSort
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController


@RestController
@RequestMapping("/medical")
@Api(tags = ["护士屏接口"])
@ApiSort(value = 3)
class BoardController @Autowired constructor(
        private val mBoardService: BoardService
) {

    @ApiOperation(value = "护士站大屏首页")
    @PostMapping("/getSchedule")
    fun getSchedule(deptCode:String): MResult<ScheduleVo> {
        mBoardService.getScheduleVo(deptCode)?.let {
            return MResult<ScheduleVo>().result(it)
        }?: return MResult<ScheduleVo>().nullData()
    }

    

    @ApiOperation(value = "护士站大屏获取病人列表")
    @PostMapping("/getPatientList")
    fun getPatientList(deptCode:String, type: String?, sex:String?): MResult<List<PatientVo>> {
        mBoardService.getPatientList(deptCode, type, sex)?.let {
            return MResult<List<PatientVo>>().result(it)
        }?: return MResult<List<PatientVo>>().nullData()
    }

    @ApiOperation(value = "护士站大屏更据病人id 获取详情信息")
    @PostMapping("/getPatientInfo")
    fun getPatientInfo(patientId:String): MResult<BedInfoVo> {
        mBoardService.getPatientInfo(patientId)?.let {
            return MResult<BedInfoVo>().result(it)
        }?: return MResult<BedInfoVo>().nullData()
    }

    @ApiOperation(value = "护士站大屏更据病人id 修改病人信息")
    @PostMapping("/editPatientInfo")
    fun editPatientInfo( cureNo:String,  outlayType:String?,mobile:String?,doctorCode:String?,nurseCode:String?,deptCode: String?, nurseLevel:String?,
    inTimer:String?): MResult<Int> {
        mBoardService.editPatientInfo(cureNo, outlayType,mobile,doctorCode,nurseCode,deptCode, nurseLevel, inTimer)?.let {
            return MResult<Int>().result(it)
        }?: return MResult<Int>().nullData()
    }

    @ApiOperation(value = "护士站大屏根据护士 医生id 获取排班信息")
    @PostMapping("/getShiftPlanInfo")
    fun getShiftPlanInfo(deptCode:String, type:String ): MResult<ShiftPlanInfo> {
        mBoardService.getShiftPlanInfo(deptCode, type)?.let {
            return MResult<ShiftPlanInfo>().result(it)
        }?: return MResult<ShiftPlanInfo>().nullData()
    }

    @ApiOperation(value = "护士站大屏获取护理标签等级列表")
    @PostMapping("/getNurseLevel")
    fun getNurseLevel(): MResult<List<NurseLevelVo> > {
        mBoardService.getNurseLevel()?.let {
            return MResult<List<NurseLevelVo>>().result(it)
        }?: return MResult<List<NurseLevelVo>>().nullData()
    }

    @ApiOperation(value = "护士站大屏添加护理标签等级")
    @PostMapping("/addNurseLevel")
    fun addNurseLevel(levelName:String?, bgColor:String?, fontColor:String?): MResult<Int> {
        mBoardService.addNurseLevel(levelName, bgColor, fontColor)?.let {
            return MResult<Int>().result(it)
        }?: return MResult<Int>().nullData()
    }

    @ApiOperation(value = "护士站大屏删除护理标签等级")
    @PostMapping("/deteleNurseLevel")
    fun deteleNurseLevel(labeleId:String): MResult<Int> {
        mBoardService.deteleNurseLevel(labeleId)?.let {
            return MResult<Int>().result(it)
        }?: return MResult<Int>().nullData()
    }

    @ApiOperation(value = "护士站大屏修改护理等级标签")
    @PostMapping("/getEditNurseLevel")
    fun getEditNurseLevel(id :Int, bgColor:String, fontColor:String, levelName:String): MResult<Int> {
        mBoardService.getEditNurseLevel(id,bgColor, fontColor, levelName)?.let {
            return MResult<Int>().result(it)
        }?: return MResult<Int>().nullData()
    }

    @ApiOperation(value = "护士站大屏添加护理等级标签")
    @PostMapping("/addNurseLevelLabel")
    fun addNurseLevelLabel(bgColor:String, fontColor:String, levelName:String,labelCat:String): MResult<Int> {
        mBoardService.addNurseLevelLabel(bgColor, fontColor, levelName, labelCat)?.let {
            return MResult<Int>().result(it)
        }?: return MResult<Int>().nullData()
    }

    @ApiOperation(value = "护士站大屏删除护理等级标签")
    @PostMapping("/deleteNurseLevelLabel")
    fun deleteNurseLevelLabel(labeleId: String): MResult<Int> {
        mBoardService.deleteNurseLevelLabel(labeleId)?.let {
            return MResult<Int>().result(it)
        }?: return MResult<Int>().nullData()
    }

    @ApiOperation(value = "护士站大屏获取护理标签列表")
    @PostMapping("/getCareLevelList")
    fun getCareLevelList(): MResult<List<CareLabelVo> > {
        mBoardService.getCareLevelList()?.let {
            return MResult<List<CareLabelVo>>().result(it)
        }?: return MResult<List<CareLabelVo>>().nullData()
    }

    @ApiOperation(value = "护士站大屏修改护理标签")
    @PostMapping("/getEditCareLevel")
    fun getEditCareLevelList(id :Int, bgColor:String, fontColor:String, labelName:String): MResult<Int> {
        mBoardService.getEditCareLevel(id,bgColor,fontColor,labelName)?.let {
            return MResult<Int>().result(it)
        }?: return MResult<Int>().nullData()
    }

    @ApiOperation(value = "护士站大屏添加病人护理标签")
    @PostMapping("/addCareLevel")
    fun addCareLevel(patientId:String?,careLabelId:String, bedCode:String?, deptCode: String?): MResult<Int> {
        mBoardService.addCareLevel(patientId, careLabelId, bedCode,deptCode)?.let {
            return MResult<Int>().result(it)
        }?: return MResult<Int>().nullData()
    }

    @ApiOperation(value = "护士站大屏删除病人护理标签")
    @PostMapping("/deleteCareLevel")
    fun deleteCareLevel(id:String): MResult<Int> {
        mBoardService.deleteCareLevel(id)?.let {
            return MResult<Int>().result(it)
        }?: return MResult<Int>().nullData()
    }

    @ApiOperation(value = "护士站大屏消息列表")
    @PostMapping("/getMessageList")
    fun getMessageList(patientId:String): MResult<List<MessageVo> > {
        mBoardService.getMessageList(patientId)?.let {
            return MResult<List<MessageVo>>().result(it)
        }?: return MResult<List<MessageVo>>().nullData()
    }

    @ApiOperation(value = "护士站大屏添加消息")
    @PostMapping("/addMessage")
    fun addMessage(patientId:String?, title:String?, context:String?, imgurl:String?, fileurl:String?, type:String?): MResult<Int> {
        mBoardService.addMessage(patientId, title,context, imgurl, fileurl, type)?.let {
            return MResult<Int>().result(it)
        }?: return MResult<Int>().nullData()
    }

    @ApiOperation(value = "护士站大屏添加手术信息")
    @PostMapping("/addOperations")
    fun addOperations(deptCode: String,patientId: String, opDoc:String, opName:String,ansDoc1:String, ansDoc2:String
   , assistDoc1:String, assistDoc2:String, assistDoc3:String, cirNurse1:String,cirNurse2:String,scrNurse1:String,scrNurse2:String,
                      opTime:String, opDate:String): MResult<Int> {
        mBoardService.addOperations(deptCode,patientId, opDoc, opName,ansDoc1, ansDoc2,
                assistDoc1, assistDoc2, assistDoc3, cirNurse1,cirNurse2,scrNurse1, scrNurse2,opTime,
                opDate)?.let {
            return MResult<Int>().result(it)
        }?: return MResult<Int>().nullData()
    }

}